# 1. 自定义模块 + 包
# 作业!!!!  生成随机验证码(n位字母)
from Game.tools import getCode
code = getCode(4)
print(code)

# 2. 内置模块(Random)
# seed(a=None, version=2)	初始化随机数生成器
# getrandbits(k)	返回具有k个随机位的Python整数
# randint(a, b)	返回介于a和b之间的随机整数
# choice(seq)	从非空序列返回一个随机元素
# shuffle(seq)	随机序列
# random()	返回范围为[0.0，1.0）的下一个随机浮点数

import random
# num =  random.random()
# num = random.randint(1,10)
# num = random.choice("abcdahkjdhkas")

# random.seed(20)
# print(random.random())
# print(random.random())
# print(random.random())

# num = random.getrandbits(1)
# print(num)

# list = [1,2,3,4,5,6,7]
# random.shuffle(list)
# print(list)



# 3. 第三方模块 (pip)
# import requests
# # 替换为你的 OpenWeatherMap API Key
# API_KEY = "d40c4facd4d7a8b18756c9e4ea305954"
# CITY_NAME = "Ningxiang"  # 替换为你想查询的城市
#
# # 构建 API 请求 URL
# url = f"http://api.openweathermap.org/data/2.5/weather?q={CITY_NAME}&appid={API_KEY}&units=metric"
#
# # 发送请求
# response = requests.get(url)
#
# # 检查请求是否成功
# if response.status_code == 200:
#     data = response.json()
#     # 解析天气数据
#     weather = data["weather"][0]["description"]
#     temperature = data["main"]["temp"]
#     humidity = data["main"]["humidity"]
#     wind_speed = data["wind"]["speed"]
#
#     # 打印天气信息
#     print(f"城市: {CITY_NAME}")
#     print(f"天气: {weather}")
#     print(f"温度: {temperature}°C")
#     print(f"湿度: {humidity}%")
#     print(f"风速: {wind_speed} m/s")
# else:
#     # print("请求失败，请检查 API Key 或城市名称。")
#     print(response.json())

